package com.school.campus.service.impl;

import java.util.List;

import com.school.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.school.campus.mapper.RepairMapper;
import com.school.campus.domain.Repair;
import com.school.campus.service.IRepairService;

/**
 * 在线报修Service业务层处理
 *
 * @author wwj
 * @date 2025-11-03
 */
@Service
public class RepairServiceImpl implements IRepairService {
    @Autowired
    private RepairMapper repairMapper;

    /**
     * 查询在线报修
     *
     * @param id 在线报修主键
     * @return 在线报修
     */
    @Override
    public Repair selectRepairById(Long id) {
        return repairMapper.selectRepairById(id);
    }

    /**
     * 查询在线报修列表
     *
     * @param repair 在线报修
     * @return 在线报修
     */
    @Override
    public List<Repair> selectRepairList(Repair repair) {
        return repairMapper.selectRepairList(repair);
    }

    /**
     * 新增在线报修
     *
     * @param repair 在线报修
     * @return 结果
     */
    @Override
    public int insertRepair(Repair repair) {
        repair.setStatus(0L);

        repair.setStaffId(null);
        repair.setUpdateTime(DateUtils.getNowDate());
        repair.setCreateTime(DateUtils.getNowDate());
        return repairMapper.insertRepair(repair);
    }

    /**
     * 修改在线报修
     *
     * @param repair 在线报修
     * @return 结果
     */
    @Override
    public int updateRepair(Repair repair,Long status) {
        repair.setStatus(status);
        repair.setUpdateTime(DateUtils.getNowDate());
        return repairMapper.updateRepair(repair);
    }

    /**
     * 批量删除在线报修
     *
     * @param ids 需要删除的在线报修主键
     * @return 结果
     */
    @Override
    public int deleteRepairByIds(Long[] ids) {
        return repairMapper.deleteRepairByIds(ids);
    }

    /**
     * 删除在线报修信息
     *
     * @param id 在线报修主键
     * @return 结果
     */
    @Override
    public int deleteRepairById(Long id) {
        return repairMapper.deleteRepairById(id);
    }
}
